public class PositionNewEditOverrideExtension{
    // This simple extension is to demonstrate overriding the save function, and how to determine if the record
    //   should be updated or inserted during the save operation.  This extension could be used on both
    //   an Edit override and a New override simultaneously.
    
    private Position__c pos;
    
    // This Boolean will help us determine whether to do Insert or Update upon Save
    private Boolean bUpdate;
    
    // The extension constructor initializes the private member
    // variable pos by using the getRecord method from the standard controller.
    public PositionNewEditOverrideExtension(ApexPages.StandardController stdController) {
        this.pos= (Position__c)stdController.getRecord();
        bUpdate = pos.id == null ? false : true;
    }
    
    public void SomeCustomFunction(){
        // Call this custom function from your visualforce page
    }
    
    public PageReference save(){
        if (bUpdate){
            update pos;
        } else {
            insert pos;
        }
        PageReference posPage = new PageReference('/' + pos.id);
        posPage.setRedirect(true);
        return posPage;
    }
   
}